package intf;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RunOSXcmd {

	public static int run(String cmd) {

		int exitVal = -1;
		try {
			Runtime rt = Runtime.getRuntime();
			Process pr = rt.exec(cmd);

			BufferedReader input = new BufferedReader(new InputStreamReader(
					pr.getInputStream()));
			String line = null;

			while ((line = input.readLine()) != null) {
				System.out.println(line);
			}

			exitVal = pr.waitFor();
			System.out.println("Exited with error code " + exitVal);

		} catch (Exception e) {
			System.out.println("@RunOSXcmd - Exception: " + e.getMessage());
		}
		return exitVal;
	}

	
	
}
